import express from 'express'

import * as userServer from '../../controllers/category.js'
import * as userTool from '../../controllers/user.js'
const router = express.Router()


router.get("/detail", async (req, res) => {
    let data = await userServer.selectUserDetail()
    res.send({
        code: 200,
        msg: "查询成功",
        data
    })
})


router.get("/info", async (req, res) => {
    let data = await userServer.selectUserInfo();
    res.send({
        code: 200,
        msg: "查询成功",
        data
    });
})

//编辑用户信息
router.post("/edit", async (req, res) => {
    let { username, nickname, email, userPic, password } = req.body;
    let data = await userTool.updateUserInfo(username, nickname, email, userPic, password);
    res.send({
        code: 200,
        msg: "修改成功",
        data
    });
})

export default router;